
<%@ page language="java" import="java.util.*,java.sql.*,telbook.JDBCUtils" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改信息</title>
<style type="text/css">
        /*表格样式*/			
        table {
            width: 90%;
            background: #ccc;
            margin: 10px auto;
            border-collapse: collapse;/*border-collapse:collapse合并内外边距(去除表格单元格默认的2个像素内外边距*/	
        }				
        th,td {
            height: 25px;
            line-height: 25px;
            text-align: center;
            border: 1px solid #ccc;
        }
        td input{
            border: none;
            outline: none;
            font-size: 16px;
            background-color:transparent;
            width:100%;
        }		
        th {
            background: #eee;
            font-weight: normal;
        }		
        tr {
            background: #fff;
        }		
        tr:hover {
            background: #cc0;
        }
        .button{
        	margin-top:3%;
        }
        .button input{
	        border-radius: 10px;
		    border: 0px;
		    width: 70px;
		    height: 30px;
		    background-color:rgb(41, 96, 212);
		    color: white;
		    font-size: 15px;
		    cursor: pointer;
        }
        .button input:hover{
        	background: green;
        }
    </style>
</head>
<body>
<%
	Object test=null;
	Cookie[]cookies=request.getCookies();
	for(int i=0;cookies!=null&&i<cookies.length;i++)
	{
		if("userbean".equals(cookies[i].getName())){
			test=cookies[i].getValue();
			break;
		}
	}
	if(test==null){
%>
	<jsp:forward page="loginin.jsp"></jsp:forward>
<% return;}%>
<% 
	Connection conn=null;
	Statement stmt=null;
	ResultSet rs=null;
	String table=null;
	String number=request.getParameter("number");
	request.getSession().setAttribute("tel", number);
	Object name=null;
	cookies=request.getCookies();
	for(int i=0;cookies!=null&&i<cookies.length;i++)
	{
		if("userbean".equals(cookies[i].getName())){
			name=cookies[i].getValue();
			break;
		}
	}
//		获取数据连接
			conn=JDBCUtils.getConnection();
		//	获取Statement对象
			stmt=conn.createStatement();
		//	发送SQL语句
			String sql="select tables from users where name='"+name+"'";
			
			rs=stmt.executeQuery(sql);
			
			while(rs.next()) {
				table=rs.getString("tables");
			}
			sql="select * from "+table+" where number='"+number+"'";
			request.getSession().setAttribute("table", table);
			rs=stmt.executeQuery(sql);
			
		
%>
	<div align="center">
		<form action="RemoveServlet" method="POST">
			<table border="1">
			<%
				while(rs.next()){
			 %>
	            <tr>
	                <th>姓名</th>
	                <td><input type="text" required name="name" value="<%out.print(rs.getString("name"));%>"></td>
	            </tr>
	            <tr>
	                <th>电话</th>
	                <td><input type="text" required name="number" value="<%out.print(rs.getString("number"));%>"></td>
	            </tr>
	            <tr>
	                <th>家庭地址</th>
	                <td><input type="text" required name="address" value="<%out.print(rs.getString("address"));%>"></td>
	            </tr>
	            <tr>
	                <th>QQ号</th>
	                <td><input type="text" required name="qq" value="<%out.print(rs.getString("qq"));%>"></td>
	            </tr>
	            <%} %>
	        </table>
	        <div style="color:red;width:100%;text-align:center;">${DBMes}</div>
	        <div class="button">
	        	<input type="submit" value="修改">
	        	<input type="reset" value="取消" style="margin-left: 20%;">
                  
            </div>
		</form>
	        
      </div> 
</body>
</html>